[System.Reflection.Assembly]::LoadFile("c:\windows\system32\inetsrv\Microsoft.Web.Administration.dll") | out-null
$serverManager = new-object -typeName "Microsoft.Web.Administration.ServerManager"

#Gather parameters to replace
$websiteIdentifier = $serverManager.Sites["LitwareHR"].Id
$publicApplicationPhysicalLocation = (resolve-path ..\bin\LitwareHR.PublicApp.WebUX)
$privateApplicationPhysicalLocation = (resolve-path ..\bin\LitwareHR.PrivateApp.WebUX)
$appServerTenantPhysicalPath = (resolve-path ..\bin\EmptyVD)


#Open configuration file
$configurationPath = (resolve-path "..\bin\LitwareHR.Portfolio.UnSecureHost\web.config")

$doc = New-Object System.Xml.XmlDocument
$doc.Load($configurationPath)

$webSiteIdentifierNode = $doc.selectSingleNode("//configuration/appSettings/add[@key='WebServerWebsiteIdentifier']")
$webSiteIdentifierNode.value = $websiteIdentifier.toString()

$publicAppPhysicalPathNode = $doc.selectSingleNode("//configuration/appSettings/add[@key='PublicAppPhysicalPath']")
$publicAppPhysicalPathNode.value = $publicApplicationPhysicalLocation.toString()

$privateAppPhysicalPathNode = $doc.selectSingleNode("//configuration/appSettings/add[@key='PrivateAppPhysicalPath']")
$privateAppPhysicalPathNode.value = $privateApplicationPhysicalLocation.toString()

$appServerTenantPhysicalPathNode = $doc.selectSingleNode("//configuration/appSettings/add[@key='AppServerTenantPhysicalPath']")
$appServerTenantPhysicalPathNode.value = $appServerTenantPhysicalPath.toString()

$webServerNode = $doc.selectSingleNode("//configuration/appSettings/add[@key='WebServer']")
$webServerNode.value = "localhost"

#Save modifed document

$doc.Save($configurationPath)


